﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using OnlineStore.Bll;

namespace OnlineStore.Dal
{
    public class DalHistoryCart
    {
        tbCustomer User;
        OnlineStoreDataContext data = new OnlineStoreDataContext();
        public DalHistoryCart(tbCustomer User)
        {
            this.User=User;
        }
        public List<bizHistoryCart> LoadHistoryCart()
        {
            var list = (from OrderDetail in data.tbOrderDetails
                        from Product in data.tbProducts
                        from Order in data.tbOrders
                        where OrderDetail.Product_ID == Product.ID 
                                && Order.Order_Id == OrderDetail.Order_ID 
                                &&Order.Customer_ID==User.Cus_ID
                        orderby OrderDetail.Order_ID
                        select new bizHistoryCart
                        {
                            Price = OrderDetail.Price.Value,
                            Product_Name = Product.Product_Name,
                            Order_ID = OrderDetail.Order_ID,
                            NumBerOrder = OrderDetail.Qty.Value,
                            Product_Id = OrderDetail.Product_ID,
                            Status = Order.Status,
                        }).ToList<bizHistoryCart>();
            return list;
        }
        
    }
}